package org.csu.jpetstore_cms.mapper;

import org.apache.ibatis.annotations.*;
import org.csu.jpetstore_cms.pojo.Order;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Insert("insert into orders(orderId, userID, orderDate, shipaddr1, shipaddr2, shipCity, shipState,shipZip, shipCountry, billAddr1, billAddr2, billCity, billState, billZip, billCountry,courier, totalPrice, billToFirstName, billToLastName, shipToFirstName, shipToLastName,creditCard, exprdate, cardType, locale,isShipped) values(?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
    void insertOrder();
    @Delete("delete from orders")
    void deleteAllOrder();
    @Delete("delete from orders where orderId=?")
    void deleteOrder(String orderId);
    @Update("update orders set (orderId, userID, orderDate, shipaddr1, shipaddr2, shipCity, shipState,shipZip, shipCountry, billAddr1, billAddr2, billCity, billState, billZip, billCountry,courier, totalPrice, billToFirstName, billToLastName, shipToFirstName, shipToLastName,creditCard, exprdate, cardType, locale, isShipped) = (?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) where orderId=? ")
    void updateOrder(String orderId, Order order);
    @Select("select * from orders")
    List<Order> getAllOrder();
    @Select("select * from orders where orderId=?")
    Order getOrder(String orderId);
    @Select("select * from orders where isShipped=0")
    List<Order> getAllUnshippedOrder();
    @Select("select * from orders where isShipped=0 and orderId=?")
    boolean isOrderShipped(String orderId);
    @Update("update orders set isShipped = 0 where orderId=?")
    boolean shipOrder(String orderId);

}
